namespace CIS
{
    using CISLib;
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class CompanyInfoBasicCustomerListPage : Page
    {
        protected DataGrid customerListDg;
        protected Image iBtnCustomer;

        private void customerListDg_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
        {
            this.customerListDg.CurrentPageIndex = e.NewPageIndex;
            this.DgDataBind();
        }

        private void DgDataBind()
        {
            this.customerListDg.DataSource = ManageCustomer.GetCustomerBasicInfo(new Guid(base.Request.QueryString["CompanyId"]));
            this.customerListDg.DataBind();
        }

        private void InitializeComponent()
        {
            this.customerListDg.PageIndexChanged += new DataGridPageChangedEventHandler(this.customerListDg_PageIndexChanged);
            base.Load += new EventHandler(this.Page_Load);
        }

        private void InitPage()
        {
            this.SetFrom();
            this.SetFromImage();
            this.customerListDg.PageSize = 14;
            this.DgDataBind();
        }

        protected override void OnInit(EventArgs e)
        {
            this.InitializeComponent();
            base.OnInit(e);
        }

        private void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.InitPage();
            }
        }

        private void SetFrom()
        {
            string language = this.Session["language"].ToString();
            string path = base.Server.MapPath("~/CIS/LanguageConfig.xml");
            this.customerListDg.Columns[0].HeaderText = ManageSystemConfig.GetSystemSetLanguage("CompanyInfoBasicCustomerListPage", "name", language, path);
            this.customerListDg.Columns[1].HeaderText = ManageSystemConfig.GetSystemSetLanguage("CompanyInfoBasicCustomerListPage", "title", language, path);
            this.customerListDg.Columns[2].HeaderText = ManageSystemConfig.GetSystemSetLanguage("CompanyInfoBasicCustomerListPage", "company", language, path);
            this.customerListDg.Columns[3].HeaderText = ManageSystemConfig.GetSystemSetLanguage("CompanyInfoBasicCustomerListPage", "gender", language, path);
            this.customerListDg.Columns[4].HeaderText = ManageSystemConfig.GetSystemSetLanguage("CompanyInfoBasicCustomerListPage", "depart", language, path);
        }

        private void SetFromImage()
        {
            switch (this.Session["language"].ToString())
            {
                case "cn":
                    this.iBtnCustomer.ImageUrl = "images/title_CustomerInfo.jpg";
                    break;

                case "en":
                    this.iBtnCustomer.ImageUrl = "images/title_CustomerInfoEn.jpg";
                    break;
            }
        }
    }
}

